home *** CD-ROM | disk | FTP | other *** search
- on start
- global S, dlast, ulast, matrix, umax, dmax, uoffset, doffset, totalu, totald, exu, totalux, stay, edx, totaldx, over
- if S = 8 then
- go(90)
- end if
- set over to 0
- set stay to 0
- set exu to 0
- set edx to 0
- set totalux to 0
- set totaldx to 0
- set totalu to 0
- set totald to 0
- set uoffset to 1
- set doffset to 10
- set umax to []
- set dmax to []
- repeat with i = 2 to 22
- puppetSprite(i, 1)
- end repeat
- repeat with i = 4 to 10
- set the visible of sprite i to 0
- end repeat
- repeat with i = 13 to 19
- set the visible of sprite i to 0
- end repeat
- repeat with i = 25 to 28
- set the visible of sprite i to 0
- end repeat
- repeat with i = 20 to 22
- set the visible of sprite i to 1
- end repeat
- set ulast to 0
- set dlast to 0
- set matrix to []
- repeat with i = 1 to 52
- add(matrix, i)
- end repeat
- puppetSprite(36, 1)
- set the visible of sprite 36 to 1
- updateStage()
- addu()
- addu()
- addd()
- addd()
- end
-
- on addu
- global umax, dmax, matrix, ulast, dlast, uoffset, doffset, totalu, totald, exu, totalux, Y
- set x to 0
- repeat while getOne(matrix, x) = 0
- set x to random(52)
- end repeat
- deleteAt(matrix, getPos(matrix, x))
- set ulast to ulast + 1
- set the castNum of sprite (uoffset + ulast) to x
- set the visible of sprite (uoffset + ulast) to 1
- add(umax, x)
- set totalu to totmax(umax)
- if cvalue(x) = 1 then
- set exu to exu + 10
- end if
- set totalux to totalu + exu
- updateStage()
- delx()
- end
-
- on addd
- global umax, dmax, matrix, ulast, dlast, uoffset, doffset, totalu, totald, stay, edx, totaldx, Y
- set x to 0
- repeat while getOne(matrix, x) = 0
- set x to random(52)
- end repeat
- deleteAt(matrix, getPos(matrix, x))
- set dlast to dlast + 1
- if count(dmax) > 0 then
- set the castNum of sprite (doffset + dlast - 1) to getAt(dmax, count(dmax))
- if cvalue(getAt(dmax, count(dmax))) = 1 then
- set edx to edx + 10
- end if
- end if
- set totald to totmax(dmax)
- set totaldx to totmax(dmax) + edx
- if (totaldx <= 16) or ((totald <= 16) and (totaldx > 21)) then
- set the castNum of sprite (doffset + dlast) to 53
- set the visible of sprite (doffset + dlast) to 1
- add(dmax, x)
- end if
- updateStage()
- end
-
- on cvalue x
- set yu to the name of cast x
- set yi to char 2 of yu
- if voidp(value(yi)) then
- return 10
- else
- return value(yi)
- end if
- end
-
- on delx
- global umax, dmax, matrix, ulast, dlast, uoffset, doffset, totalu, totald, totalux
- if totalu > 21 then
- lose()
- exit
- end if
- if (totalu = 21) or (totalux = 21) then
- win()
- exit
- end if
- if count(umax) = 5 then
- win()
- exit
- end if
- end
-
- on win
- global over, S
- set over to 1
- set the visible of sprite 36 to 0
- go(11)
- end
-
- on lose
- global over
- set over to 1
- set the visible of sprite 20 to 0
- set the visible of sprite 21 to 0
- go(12)
- end
-
- on totmax x
- set yu to 0
- repeat with i in x
- set yu to yu + cvalue(i)
- end repeat
- return yu
- end
-
- on stay
- global umax, dmax, matrix, ulast, dlast, uoffset, doffset, totalu, totald, stay, totalux, totaldx, edx, exu, totalub, totaldb
- set stay to 0
- repeat while (totaldx <= 16) or ((totald <= 16) and (totaldx > 21))
- addd()
- end repeat
- if totald > 21 then
- win()
- exit
- end if
- if (totald = 21) or (totaldx = 21) then
- lose()
- exit
- end if
- calcbest()
- if totalub >= totaldb then
- win()
- else
- lose()
- end if
- end
-
- on calcbest
- global totald, totalu, totaldx, totalux, edx, exu, totaldb, totalub
- set totaldb to totaldx
- set totalub to totalux
- repeat with i = 1 to edx / 10
- if totaldb > 21 then
- set totaldb to totaldb - 10
- next repeat
- end if
- exit repeat
- end repeat
- repeat with i = 1 to exu / 10
- if totalub > 21 then
- set totalub to totalub - 10
- next repeat
- end if
- exit repeat
- end repeat
- end
-